import { MapRoomState } from './schema/MapRoomState';
import { BaseRoom } from './BaseRoom';
import { Client } from '@colyseus/core';

export class XingXiuCunRoom extends BaseRoom {
    maxClients = 4;
    autoDispose = false;

    onCreate(options: any) {
        super.onCreate(options);
        this.state = new MapRoomState();  // ✅ 正确的写法
        console.log(`🌟 星秀村房间 ${this.roomId} 已创建`);
    }

    onJoin(client: Client, options: any) {
        super.onJoin(client, options);
        console.log(`🎮 ${client.sessionId} 加入 ${this.roomId}`);
    }


    async onLeave(client: Client, consented: boolean) {
        super.onLeave(client, consented);
        this.state.players.delete(client.sessionId); // ✅ 离开时移除玩家
    }
}
